﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#include "CommandButtonMenuDefinitionReference.h"
#include "GbmpNew.h"
#include "ControlDefinitionChangeEvent.h"
#include "IMenuItemDefinition.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h"

namespace gcmp
{
    gcmp::CommandButtonMenuDefinitionReference::CommandButtonMenuDefinitionReference(CommandButtonMenuDefinition* pCommandButtonMenuDefinition)
        :m_wpCommandButtonMenuDefiniton(pCommandButtonMenuDefinition)
    {

    }

    CommandButtonMenuDefinitionReference::~CommandButtonMenuDefinitionReference()
    {

    }

    std::wstring CommandButtonMenuDefinitionReference::GetId() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, L"", L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetId();
    }

    std::wstring CommandButtonMenuDefinitionReference::GetCaption() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, L"", L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetCaption();
    }

    std::wstring CommandButtonMenuDefinitionReference::GetTooltip() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, L"", L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetTooltip();
    }

    std::wstring CommandButtonMenuDefinitionReference::GetCommandId() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, L"", L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetCommandId();
    }

    std::wstring CommandButtonMenuDefinitionReference::GetIconPath() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, L"", L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetIconPath();
    }

    bool CommandButtonMenuDefinitionReference::SetCaption(const std::wstring& caption)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->SetCaption(caption);
    }

    bool CommandButtonMenuDefinitionReference::SetIconPath(const std::wstring & iconPath)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->SetIconPath(iconPath);
    }

    bool CommandButtonMenuDefinitionReference::SetTooltip(const std::wstring & tooltip)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->SetTooltip(tooltip);
    }

    bool CommandButtonMenuDefinitionReference::SetCommandId(const std::wstring& commandId)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->SetCommandId(commandId);
    }

    gcmp::IMenuItemDefinition* CommandButtonMenuDefinitionReference::GetItem(const std::wstring& id) const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, nullptr, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetItem(id);
    }

    std::vector<IMenuItemDefinition*> CommandButtonMenuDefinitionReference::GetAllItems() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, std::vector<IMenuItemDefinition*>(), L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->GetAllItems();
    }

    bool CommandButtonMenuDefinitionReference::AddItem(OwnerPtr<IMenuItemDefinition> opMenuItemDefinition)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->AddItem(TransferOwnership(opMenuItemDefinition));
    }

    bool CommandButtonMenuDefinitionReference::InsertItem(const std::wstring& beforeId, OwnerPtr<IMenuItemDefinition> opMenuItemDefinition)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->InsertItem(beforeId, TransferOwnership(opMenuItemDefinition));
    }

    void CommandButtonMenuDefinitionReference::DeleteAllItems()
    {
        DBG_WARN_AND_RETURN_VOID_UNLESS(m_wpCommandButtonMenuDefiniton, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        m_wpCommandButtonMenuDefiniton->DeleteAllItems();
    }

    bool CommandButtonMenuDefinitionReference::IsAutoChangeDisplayInformation() const
    {
        DBG_WARN_AND_RETURN_FALSE_UNLESS(m_wpCommandButtonMenuDefiniton, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->IsAutoChangeDisplayInformation();
    }

    bool CommandButtonMenuDefinitionReference::SetAutoChangeDisplayInformation(bool isModifyDisplayInformation)
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->SetAutoChangeDisplayInformation(isModifyDisplayInformation);
    }

    bool CommandButtonMenuDefinitionReference::IsVisible() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->IsVisible();
    }

    bool CommandButtonMenuDefinitionReference::IsEnabled() const
    {
        DBG_WARN_AND_RETURN_UNLESS(m_wpCommandButtonMenuDefiniton, false, L"m_wpCommandButtonMenuDefiniton为空",L"GDMPLab",L"2024-03-30");
        return m_wpCommandButtonMenuDefiniton->IsEnabled();
    }

    gcmp::IControlDefinitionChangeEvent* CommandButtonMenuDefinitionReference::GetControlDefinitionChangeEvent() const
    {
        if (m_wpCommandButtonMenuDefiniton)
        {
            return m_wpCommandButtonMenuDefiniton->GetControlDefinitionChangeEvent();
        }
        return nullptr;
    }

}

